<?php
/**
 * Created by PhpStorm.
 * User: ljc
 * Date: 2018/6/17
 * Time: 11:02
 */

namespace app\home\controller;



use houdun\core\Controller;
use houdun\view\View;
use system\model\Grade;
use system\model\Student;


class Entry extends Controller
{

	public function index(){
		$data=Grade::getAll();
		return view ('',compact('data'));
	}
	public function add(){
		if(IS_POST){
			Grade::insert($_POST);
			$this->setRedirct ('?a=index')->message ('添加成功');
		}
		return view();
	}
	public function edit(){
		$id=isset($_GET['id'])?$_GET['id']:header('Location:/');
		$data=Grade::find($id);
		if(IS_POST){
			Grade::where("id={$id}")->update($_POST);
			$this->setRedirct ('?a=index')->message ('修改成功');
		}
		return view('',compact('data'));
	}
	public function del(){
		$id=isset($_GET['id'])?$_GET['id']:header('Location:/');
		Grade::where("id={$id}")->del();
		$this->setRedirct ('?a=index')->message ('删除成功');
	}
}